package com.yanfan.point.service.impl;

import java.util.Arrays;
import java.util.List;
import com.yanfan.common.utils.DateUtils;
import com.yanfan.common.utils.StringUtils;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yanfan.point.mapper.IbmsPointMapper;
import com.yanfan.point.domain.IbmsPoint;
import com.yanfan.point.service.IIbmsPointService;

/**
 * 点位Service业务层处理
 *
 * @author genluo
 * @date 2024-10-09
 */
@Service
public class IbmsPointServiceImpl extends ServiceImpl<IbmsPointMapper, IbmsPoint> implements IIbmsPointService {
    @Autowired
    private IbmsPointMapper ibmsPointMapper;


    /**
     * 查询点位列表
     *
     * @param ibmsPoint 点位
     * @return 点位
     */
    @Override
    public List<IbmsPoint> queryPageList(IbmsPoint ibmsPoint) {
        LambdaQueryWrapper<IbmsPoint> lqw = buildQueryWrapper(ibmsPoint);
        return ibmsPointMapper.selectList(lqw);
        //连表查询可用该方法，在此方法SQL语句上进行扩展
        //return ibmsPointMapper.queryPageList(ibmsPoint);
    }

    /**
    * 分页查询条件
    * @return
    */
    private LambdaQueryWrapper<IbmsPoint> buildQueryWrapper(IbmsPoint bo) {
        LambdaQueryWrapper<IbmsPoint> lqw = Wrappers.lambdaQuery();
        lqw.eq(StringUtils.isNotBlank(bo.getDeviceId()), IbmsPoint::getDeviceId, bo.getDeviceId());
        lqw.eq(bo.getDeviceGroupId() != null, IbmsPoint::getDeviceGroupId, bo.getDeviceGroupId());
        lqw.like(StringUtils.isNotBlank(bo.getGroupName()), IbmsPoint::getGroupName, bo.getGroupName());
        lqw.eq(bo.getDeviceTypeId() != null, IbmsPoint::getDeviceTypeId, bo.getDeviceTypeId());
        lqw.eq(bo.getAreaId() != null, IbmsPoint::getAreaId, bo.getAreaId());
        lqw.eq(bo.getFloorId() != null, IbmsPoint::getFloorId, bo.getFloorId());
        lqw.eq(bo.getBuildingId() != null, IbmsPoint::getBuildingId, bo.getBuildingId());
        lqw.eq(bo.getXaxis() != null, IbmsPoint::getXaxis, bo.getXaxis());
        lqw.eq(bo.getYaxis() != null, IbmsPoint::getYaxis, bo.getYaxis());
        lqw.eq(bo.getZaxis() != null, IbmsPoint::getZaxis, bo.getZaxis());
        lqw.eq(StringUtils.isNotBlank(bo.getIsBinding()), IbmsPoint::getIsBinding, bo.getIsBinding());
        lqw.eq(bo.getCreateDept() != null, IbmsPoint::getCreateDept, bo.getCreateDept());
        return lqw;
    }



}
